package com.turing.common.entity;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author fangyihang
 * @date Created in 2022/7/31 10:13
 * 表格结构化后的基类
 */
@Data
public class ParseContentVO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 单元格里的内容
     */
    private String value;

    /**
     * 当前单元格上方表头
     */
    private List<String> topTitle;

    /**
     * 当前单元格左方表头
     */
    private List<String> leftTitle;

    /**
     * 行信息
     */
    private List<Integer> rowNum;

    /**
     * 列信息
     */
    private List<Integer> columnNum;

//    /**
//     * 模型返回的当前行的具体信息
//     */
//    private JavaTableParses.JavaTableParse javaTableParse;

    /**
     * 位置信息
     */
    private List<Integer> linePos;

    private String lineId;

    /**
     * 获得当前单元格表头内容(list从右往左拼)
     * @return String
     */
    public String getTopTitle(){
        if (topTitle!=null && topTitle.size()>0){
            if (topTitle.size() == 1){
                return topTitle.get(0);
            }
            StringBuilder topKey = new StringBuilder();
            for (int i = topTitle.size() - 1; i >= 0; i--) {
                topKey.append(topTitle.get(i));
                if (i!=0){
                    topKey.append(",");
                }
            }
            return topKey.toString();
        }
        return "";
    }

    /**
     * 获得当前单元格左方表头（list从右往左拼）
     * @return String
     */
    public String getLeftTitle(){
        if (leftTitle!=null && leftTitle.size()>0){
            if (leftTitle.size() == 1){
                return leftTitle.get(0);
            }else {
                StringBuilder topKey = new StringBuilder();
                for (int i = leftTitle.size() - 1; i >= 0; i--) {
                    topKey.append(leftTitle.get(i));
                    if (i!=0){
                        topKey.append(",");
                    }
                }
                return topKey.toString();
            }
        }
        return "";
    }

    public List<String> getTopTitleList() {
        return this.topTitle;
    }

    public List<String> getLeftTitleList() {
        return this.leftTitle;
    }
}
